package Management;

import java.io.File;

import javax.swing.Icon;
import javax.swing.filechooser.FileSystemView;

public class Animation {
	private String			name;		//name of anime				文件名:	 [SumiSora][World_Destruction][07][GB][RV10].rmvb
	private String			path;		//directionary of anime     目录:	 E:\comic\七月新番
	private String[]		tag;		//key word of anime			
	private File			animeFile;	//File class of anime
	private boolean			isDirectory;
	private long			size;
	private long			lastModified;
	private Icon			icon;

	/**
	 * getAnimeFile()
	 * @return
	 */
	public File getAnimeFile() {
		return animeFile;
	}

	//	private Rules			thisRuleName;
	private AnimationRoute	parentList;	
	
	/**
	 * 构造方法
	 * @param filename
	 */
	public Animation(String filename) {
		this(new File(filename));
	}
	
	/**
	 * 构造方法
	 * @param anime
	 */
	public Animation(File anime) {
		name = anime.getName();
		path = anime.getParent();	
		this.animeFile = anime; 
		this.isDirectory = anime.isDirectory();
		this.size = anime.length();
		this.lastModified = anime.lastModified();
		this.icon = FileSystemView.getFileSystemView().getSystemIcon(anime);
	}
	
	/**
	 * 
	 * @return this icon of file;
	 */
	public Icon getIcon() {
		return icon;
	}

	/**
	 * 
	 * @return size;
	 */
	public long getSize() {
		return size;
	}

	/**
	 * 
	 * @return last time when change the file;
	 */
	public long getLastModified() {
		return lastModified;
	}

	/**
	 * get isDirectory;
	 * @return
	 */
	public boolean isDirectory() {
		return isDirectory;
	}

	/**
	 * get the TypeName of the Animator File      文件类型: rmvb
	 * @return fileType
	 */
	public String getFileType() {
		if (!animeFile.isDirectory()) {
			String[] names 		= name.split("[.]");
			String fileType 	= names[names.length - 1];
			return fileType;
		}
		else {
			String fileType = "Directory";
			return fileType;
		}
	}

	/**
	 * 返回它的AnimatorRoute
	 * @return parentList
	 */
	public AnimationRoute getParentList() {
		return parentList;
	}

	/**
	 * 设置AnimatorRoute
	 * @param parentList
	 */
	public void setParentList(AnimationRoute parentList) {
		this.parentList = parentList;
	}

	/**
	 * 返回它的名字
	 * @return name
	 */
	public String getName() {
		return name;
	}

	/**
	 * 设置name
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * 获得path
	 * @return path
	 */
	public String getPath() {
		return path;
	}

	/**
	 * 设置path
	 * @param path
	 */
	public void setPath(String path) {
		this.path = path;
	}

	/**
	 * 获得tag
	 * @return tag
	 */
	public String[] getTag() {
		return tag;
	}

	/**
	 * 设置tag
	 * @return tag
	 */
	public void setTag(String[] tag) {
		this.tag = tag;
	}

//	public static void main(String[] args) {
//		File animeF = new File("E:/comic/七月新番/[SumiSora][World_Destruction][07][GB][RV10].rmvb");
//		Animation anime = new Animation(animeF);
//		System.out.println(anime.getName());
//		System.out.println(anime.getPath());
//	}
}
